package com.jkdz.spyke.rs
{
	import com.jkgh.remedy.core.client.*;
	import flash.utils.ByteArray;

	public class SpykeWidgetConstructorRemoter implements RemedyRemoter
	{
		private var mo:SpykeWidgetConstructor;

		public function SpykeWidgetConstructorRemoter(mo:SpykeWidgetConstructor)
		{
			this.mo = mo;
		}

		public function call(methodID:int, connection:RemedyClientServerConnection, onReturn:Function):void
		{
			switch (methodID)
			{
				case 70:
					mo.getAvailableWidgets(function(ret:Vector.<String>):void {
						onReturn(ret, RemedyArrayClassManager.forType(1));
					});
					break;
				case 69:
					var a_69:String = (String)(RemedyStringClassManager.INSTANCE.readWithGraph(connection, new Vector.<Object>()));
					mo.createNewWidget(a_69, function(ret:SpykeWidget):void {
						onReturn(ret, RemedyMOClassManager.INSTANCE);
					});
					break;
			}
		}

		public function run(methodID:int, connection:RemedyClientServerConnection):void
		{
			switch (methodID)
			{
				case 67:
					mo.unPublish();
					break;
				case 66:
					mo.publish();
					break;
			}
		}
	}
}
